import * as types from './mutation-types'

const mutations = {
    [ types.PUSH_CART ]( state, product ) {
        state.items.push( {
            id: product.id,
            title: product.title,
            number: 1,
        } )
    },

    [ types.ADD_ITEM ]( state, product ) {
        const cartItem = state.items.find( item => item.id === product.id );
        cartItem.number++
    }
}

export default mutations
